package com.epam.photographer.DAO;

import java.util.ArrayList;

import org.springframework.stereotype.Component;

import com.epam.photographer.DataBase.TempDataBase;
import com.epam.photographer.model.Album;
import com.epam.photographer.model.PhotoWrapper;
import com.epam.photographer.model.Photographer;
@Component
public class Dao implements IDao{
	
	

	public void addPhotographer(Photographer photographer){
		TempDataBase.getPhotographers().add(photographer);
		
	}

	public Photographer getPhotographerById(int id){
		
		for (Photographer photographer : TempDataBase.getPhotographers()) {
			if(photographer.getId() == id){
				return photographer;
			}
		}
		return null;
	}
	public void addPhotoWrapper(PhotoWrapper photo){
		TempDataBase.getPhotos().add(photo);
		
	}

	public PhotoWrapper getPhotoWrapperById(int id){
		
		for (PhotoWrapper photoWrapper : TempDataBase.getPhotos()) {
			if(photoWrapper.getId() == id){
				return photoWrapper;
			}
		}
		return null;
	} 
	public void addAlbum(Album album){
		TempDataBase.getAlbums().add(album);
		
	}

	public Album getAlbumById(int id){
		
		for (Album album: TempDataBase.getAlbums()) {
			if(album.getId() == id){
				return album;
			}
		}
		return null;
	}

	@Override
	public ArrayList<Photographer> getPhotographersList() {
		
		return TempDataBase.getPhotographers();
	}

	@Override
	public ArrayList<PhotoWrapper> getPhotoWrappersList() {
		
		return TempDataBase.getPhotos();
	}

	@Override
	public ArrayList<Album> getAlbumsList() {
		
		return TempDataBase.getAlbums();
	} 
}
